This is G o o g l e's cache of http://www.rockbox.org/twiki/bin/view/Main/CrossCompiler as retrieved on 8 Sep 2005 04:31:08 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:UNI6yxENsyoJ:www.rockbox.org/twiki/bin/view/Main/CrossCompiler+site:rockbox.org+twiki+crosscompiler&hl=en&client=firefox


Google is neither affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: crosscompiler 
These terms only appear in links pointing to this page: twiki

Rockbox . Main . CrossCompiler

 Rockbox Logo 

home
download
documentation
mailing lists
wiki
IRC
forums
daily builds
feature requests
bug reports
patches


SourceForge.net Logo

Rockbox > Main > RockboxDevelopment > CrossCompiler
Main . { Users | Changes | Index | Search | Register | Go }

Building a cross compiler

Host environment

In this example I will assume that you are running Linux with the bash shell (or cygwin). We will only build the C compiler along with the assembler, linker and stuff. Note that the procedure is exactly the same if you are running cygwin on Windows, and on Macintosh OS X.

Note this is currently the only way to get a working toolchain on cygwin for Windows :-) ALERT! Experiments have shown that gcc-3.4.x for cygwin does not build binutils correctly! (at least not for m68k - not sure about other versions) For now, when building on cygwin, get/downgrade to gcc-3.3.3 first. Then use this version of gcc to build the cross m68k binutils and gcc. You may use cygwin-gcc-3.3.3 to build m68k-3.4.4 successfully.

Download the source code

You will need the following archives:

GCC 4.0.x does currently not work with Rockbox. Don't try it unless you are prepared to fix the Rockbox code to work with it. Don't bother us with questions on how to fix it. If you're not up to it yourself, then stay with the versions stated below.

Coldfire

  • Binutils needs flex installed in order to compile. On Mandrake I did urpmi flex

  • Binutils require gettext, bison, and m4 installed to compile (urpmi gettext, urpmi bison, and urpmi m4 on Mandrake, apt-get install gettext and bison and m4 on Debian)

  • Get gcc 3.4.x - you only need gcc-core-3.4.x.tar.bz2 (latest is recommended - 3.4.4 as of this writing)

  • The build and install procedure for m68k gcc and binutils is done exactly as described below. It is not cpu-specific.

Note: on some cygwin systems, the compilation of the multilibs may fail (...fmovem.l...blabla...illegal operands...). I don't know why this happens, but there is a workaround. After downloading and unpacking the gcc source code, download the patch on the bottom of this page and install it. The patch is made on gcc-3.4.3, but it might work on earlier versions too.

   /home/linus> patch -p0 < gcc.patch

With this patch, m68k-elf-gcc will only work for the m5200 target, not for m68040 etc.

Note 2: This patch doesn't work for gcc 3.4.4 due to a changed Makefile layout. I provided a new patch for gcc 3.4.4, which will disable support for m68040 only. All other targets still work. - JensArnold

Note 3: This gcc 3.4.4 patch also fixes failed builds on Mac OS X with make output errors such as:

make[2]: *** [libgcc/m68040/_fixunsdfsi.o] Error 1
make[1]: *** [stmp-multilib] error 2
make: *** [all-gcc] error 2

CalmRISC16

Get gcc & binutils directly from cvs. We'll prepare tarballs when the code gets stable enough.
   cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/gemoss login 
 (just press enter when password is requested)
   cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/gemoss co binutils-2.15
   cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/gemoss co gcc-3.4

  • The build and install procedure for CalmRISC16 gcc and binutils is done exactly as described below. It is not cpu-specific.

Gdb is simply not available. Sorry. Alternatively we suggest you use the GminiEmulator we have made.

SH-based Archos

  • Get gcc 3.3.x - you only need gcc-core-3.3.x.tar.bz2 (latest is recommended - 3.3.6 as of this writing)

If you want to stay out of trouble, use the versions stated above. If you want to live on the edge you can try building with the later versions. Also, if you want to build old versions of Rockbox (earlier than 2004-07-24), you will want to use binutils 2.11 and gcc 3.0.4.

Yes, we know that there are newer versions of the compiler (3.4.4 when writing this) but the 3.3.x version creates much more compact code than 3.4.x, and that is crucial for the SH-based Archoses, as there are tight limits.

Target CPU

The Archos Jukebox models have an SH-1 CPU, so the target name is sh-elf.

The iRiver iHp-xxx models have a Coldfire CPU, so the target name is m68k-elf.

The Archos Gmini 1xx, SP and 2xx have a CalmRISC16 CPU, so the target name is calmrisc16-unknown-elf

Note: The rest of this tutorial describes how to build the SH-1 cross compiler. To build a ColdFire or CalmRISC16 compiler, substitute sh-elf with your target name from above in the --target parameter, and use another path in the --prefix parameter as well.

OS X only: start the bash shell

   [Linus-Computer:~] linus% bash

Unpack the archives

(some may need to get the sources off CVS servers, as noted above)

   /home/linus> tar zxf binutils-2.16.tar.gz
   /home/linus> tar zxf gcc-3.3.4.tar.gz
   /home/linus> tar zxf gdb-6.1.1.tar.gz

Create the directory tree

   /home/linus> mkdir build
   /home/linus> cd build
   /home/linus/build> mkdir binutils
   /home/linus/build> mkdir gcc
   /home/linus/build> mkdir gdb

Choose location

Now is the time to decide where you want the tools to be installed. This is the directory where all binaries, libraries, man pages and stuff end up when you do "make install".

In this example I have chosen "/home/linus/sh1" as my installation directory, or prefix as it is called. Feel free to use any prefix, like /usr/local/sh1 for example.

Build binutils

We will start with building the binutils (the assembler, linker and stuff). This is pretty straightforward. We will be installing the whole tool chain in the /home/linus/sh1 directory.

If you are building on a Macintosh OS X machine, you have to disable the precompiled headers:

   /home/linus> export CC="gcc -no-cpp-precomp"

Then configure, make and install:

   /home/linus> cd build/binutils
   /home/linus/build/binutils> ../../binutils-2.16/configure --target=sh-elf --prefix=/home/linus/sh1
   /home/linus/build/binutils> make
   /home/linus/build/binutils> make install

Note : there's currently a bug with the binutils (tex)info install for CalmRISC16. It can safely be skipped with

 make -k install

Build GCC

Now you are ready to build GCC. To do this, you must have the newly built binutils in the PATH.

Then set the PATH, configure and make:

   /home/linus> export PATH=/home/linus/sh1/bin:$PATH
   /home/linus> cd build/gcc
   /home/linus/build/gcc> ../../gcc-3.3.4/configure --target=sh-elf --prefix=/home/linus/sh1 --enable-languages=c
   /home/linus/build/gcc> make
   /home/linus/build/gcc> make install

GCC 3.3.X for SH1

To build GCC 3.3.X for SH1, you need a fancy work-around as otherwise the gcc build will fail:

        /home/linus> cd gcc-3.3.4
        /home/linus/gcc-3.3.4> ln -s ../newlib-1.11.0/newlib newlib
  • now, build gcc as described above

Note: This workaround might no longer be necessary for the latest gcc 3.3 (3.3.6). It worked for me without the workaround on cygwin (drastically reducing the build time), but didn't on debian... JensArnold

Build GDB

If you are planning to debug your code with GDB, you have to build it as well.

   /home/linus> cd build/gdb
   /home/linus/build/gdb> ../../gdb-6.1.1/configure --target=sh-elf --prefix=/home/linus/sh1
   /home/linus/build/gdb> make
   /home/linus/build/gdb> make install

Done

If someone up there likes you, you now have a working tool chain.

Good luck!

Linus

Attachment: Action: Size: Date: Who: Comment:
gcc.patch action 446 04 May 2005 - 07:51 LinusNielsenFeltzing Patch for failed cygwin Coldfire builds
gcc-3.4.4.patch action 659 01 Jun 2005 - 23:06 JensArnold Patch for failed cygwin coldfire builds (gcc 3.4.4

{ Edit | View raw | Attach | Ref-By | Printable | Diffs | r1.48 | > | r1.47 | > | r1.46 | More }
Revision r1.48 - 30 Aug 2005 - 21:46 GMT - JensArnold
Parents: RockboxDevelopment
Copyright © 1999-2005 by the contributing authors.